﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace timetableasy.Models
{
    public class ClassRoomRepository : Controller
    {
        private TimeTableDBDataContext db = new TimeTableDBDataContext();

        //Query Methods
        public IQueryable<ClassRoom> FindAllClassRooms()
        {
            return db.ClassRooms;
        }

        public ClassRoom GetClassRoomById(int id)
        {
            return db.ClassRooms.SingleOrDefault(c => c.ClassRoomId == id);
        }

        //Insert/Delete Methods

        public void Add(ClassRoom classRoom)
        {
            db.ClassRooms.InsertOnSubmit(classRoom);
        }

        public void Delete(ClassRoom classRoom)
        {
            db.ClassRooms.DeleteOnSubmit(classRoom);
        }

        //Persistence

        public void Save()
        {
            db.SubmitChanges();
        }

    }
}
